<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="chrome=1;IE=edge">
    <meta name="viewport" content="user-scalable=no">
    <!-- vue2 -->
    <script src="/examples/js/vue.min.js"></script>
    <!-- 示例演示-公共样式 -->
    <link rel="stylesheet" href="/examples/css/railView.css" type="text/css" />
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <!-- RailUnit 样式 -->
    <link rel="stylesheet" href="/RailUnit/RailUnit.umd.css" type="text/css">
    <!-- RailUnit 插件 -->
    <script type="text/javascript" src="/RailUnit/RailUnit.umd.js" charset="utf-8"></script>
</head>
<body>
    <div id="app">
        <div id="buttom-container">
            <el-button type="info" @click="handleRotate('X')">X轴旋转</el-button>
            <el-button type="info" @click="handleRotate('Y')">Y轴旋转</el-button>
            <el-button type="info" @click="handleRotate('Z')">Z轴旋转</el-button>
            <el-button type="info" @click="showCard = !showCard">自定义轴旋转</el-button>
        </div>
        <el-card class="box-card" v-show="showCard">
            <div slot="header" class="clearfix">
              <span>旋转设置</span>
              <el-button class="close-btn" type="text" @click="hideModel">×</el-button>
            </div>
            <div class="card-container">
                <el-form 
                    ref="form" 
                    :model="formValues" 
                    label-width="80px"
                >
                    <el-form-item label="X轴：">
                        <el-input v-model.number="formValues.xAxis"></el-input>
                    </el-form-item>
                    <el-form-item label="Y轴：">
                        <el-input v-model.number="formValues.yAxis"></el-input>
                    </el-form-item>
                    <el-form-item label="Z轴：">
                        <el-input v-model.number="formValues.zAxis"></el-input>
                    </el-form-item>
                </el-form>
                <div class="modal-footer">
                    <el-button size="small" type="primary" @click="handleSubmit">确认</el-button>
                </div>
            </div>
        </el-card>
        <div id="viewer" style="width:100%;height:100%;position:relative;float:left"></div>
    </div>
    
    <script id="viewerStartup" type="module">
        const vm = new Vue({
            el: '#app',
            data: {
                bimViewer: null,
                showCard: false,
                formValues: {
                    xAxis: 0,
                    yAxis: 0,
                    zAxis: 0
                }
            },
            mounted() {
                this.bimViewerFn()
            },
            methods: {
                // 初始化模型
                bimViewerFn() {
                    this.bimViewer = new MyViewer({
                        serverUrl: '/RailUnit/',
                        containerElement: document.getElementById('viewer'),
                        nodeVisible: false
                    })
                    this.bimViewer.loadModel2('jianzhu')
                },
                handleRotate(mode) {
                    this.bimViewer.setModelRotationAxis(mode)
                },
                handleSubmit() {
                    const { xAxis, yAxis, zAxis } = this.formValues
                    console.log(xAxis, yAxis, zAxis);
                    this.bimViewer.setModelRotationAxis({X: xAxis, Y: yAxis, Z: zAxis});
                },
                hideModel() {
                    this.showCard = false
                    this.$refs['form'].resetFields();
                }
            }
        })
    </script>
</body>
</html>
